package Tools;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.PatternSyntaxException;

/**
 * This class contains  methods "static void main(String[] a)"
 * @author Ivan
 *
 */
public class FilesManager {

    /**
     * @param args
     */
    public static void main(String[] args) {
        
        TBrowser browser = new TBrowser();
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {

            System.out.print("Selec Mode : \n"
                    + "\t(1)Show files in directory ;" + "\n"
                    + "\t(2) Show Tree of directories and files;" + "\n"
                    + "\t(3) Show files in directory with exteded information and pre-specified mask of search." + "\n");

            int mode = Integer.parseInt(reader.readLine());

            switch (mode) {
                case 1:
                    System.out.print("directory : ");
                    browser.showFiles(reader.readLine());
                    break;

                case 2:
                    System.out.print("directory : ");
                    browser.showTreeOfDirectories(reader.readLine());
                    break;

                case 3:
                    String dir,mask;

                    System.out.print("directory : ");
                    dir = reader.readLine();

                    System.out.print("mask of search : ");
                    mask = reader.readLine();

                    try {
                        browser.showFiles(dir,  new MaskCaseSensitive(mask));
                    } catch (PatternSyntaxException e) {
                        e.getMessage();
                    } catch (MaskCaseSensitive.InitializationMaskException e) {
                        e.getMessage();
                    }


                    break;
                default:
                    reader.close();
                    break;
            }

        } catch (IOException e) {
            System.out.print("Error of read! " + e.getMessage());
        } catch (NumberFormatException e) {
            System.out.print("Error select mode!  " + e.getMessage());
        }

    }
}
